package com.miao.im.common.enums;

/**
 * @Auther: miaoguoxin
 * @Date: 2021/2/25 17:29
 * @Description:
 */
public enum Command {
    AUTH(1, "权限验证请求"),
    P2P_SENDER(2, "单聊发送方请求(sender to server)"),
    P2P_NOTIFY(3, "单聊发送给接收方请求(server to receiver)"),
    P2P_NOTIFY_ACK(4, "单聊接收方响应(receiver to server)"),
    P2P_NOTIFY_TO_SENDER_ACK(5, "单聊发送方接收到接收方的ack(receiver to sender)"),
    OFFLINE_MSG_PULL(6, "离线消息拉取请求"),
    OFFLINE_MSG_ACK(7, "离线消息拉取确认请求"),
    GENERATE_ID(98, "生成id"),
    HEART_BEAT(99, "心跳"),
    ERROR(100, "错误处理"),
    KICK_OUT(101, "踢出");
    private int code;

    private String value;

    Command(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public static Command getByCode(int code) {
        for (Command e : Command.values()) {
            if (e.getCode() == code) {
                return e;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }
}
